#coding=utf-8
from CtripSpider import fetch_hotel_info;
from CtripSpider import fetchHotelUrl;
from MysqlOperate import saveOrUpdateHotelInfo;
from MysqlOperate import saveHotelList;
from MysqlOperate import queryHotelInfoExist;
from MysqlOperate import queryAllHotelList;
from MysqlOperate import updateSpideredCity;
from MysqlOperate import queryCityCodeByName;
import datetime;
import sys;

'''
定义的主方法入口
'''
def main(argv):
    if len(argv) < 2:
        print("Usage: python3 main.py fetchHotelListFromCtrip|fetHotelInfosFromCtrip");
        exit()
    if (argv[1] == 'fetchHotelListFromCtrip'):
        fetchHotelListFromCtrip();
    elif (argv[1] == 'fetHotelInfosFromCtrip'):
        fetHotelInfosFromCtrip();
'''
从携程官网获取分页的青旅列表
'''
def fetchHotelListFromCtrip():
    ctripCity = [{"display":"北京","data":"Beijing|北京|1","group":"B"},{"display":"上海","data":"Shanghai|上海|2","group":"S"},{"display":"天津","data":"Tianjin|天津|3","group":"T"},{"display":"重庆","data":"Chongqing|重庆|4","group":"C"},{"display":"大连","data":"Dalian|大连|6","group":"D"},{"display":"青岛","data":"Qingdao|青岛|7","group":"Q"},{"display":"西安","data":"Xian|西安|10","group":"X"},{"display":"南京","data":"Nanjing|南京|12","group":"N"},{"display":"苏州","data":"Suzhou|苏州|14","group":"S"},{"display":"杭州","data":"Hangzhou|杭州|17","group":"H"},{"display":"厦门","data":"Xiamen|厦门|25","group":"X"},{"display":"成都","data":"Chengdu|成都|28","group":"C"},{"display":"深圳","data":"Shenzhen|深圳|30","group":"S"},{"display":"广州","data":"Guangzhou|广州|32","group":"G"},{"display":"三亚","data":"Sanya|三亚|43","group":"S"},{"display":"台北","data":"Taipei|台北|617","group":"T"},{"display":"香港","data":"Hong Kong|香港|58","group":"H"},{"display":"济南","data":"Jinan|济南|144","group":"J"},{"display":"宁波","data":"Ningbo|宁波|375","group":"N"},{"display":"沈阳","data":"Shenyang|沈阳|451","group":"S"},{"display":"武汉","data":"Wuhan|武汉|477","group":"W"},{"display":"阿坝","data":"abazhou|阿坝|1838","group":"A"},{"display":"阿克苏","data":"Akesu|阿克苏|173","group":"A"},{"display":"阿勒泰","data":"Aletai|阿勒泰|175","group":"A"},{"display":"阿里","data":"Ali|阿里|97","group":"A"},{"display":"安康","data":"Ankang|安康|171","group":"A"},{"display":"安庆","data":"Anqing|安庆|177","group":"A"},{"display":"鞍山","data":"Anshan|鞍山|178","group":"A"},{"display":"安顺","data":"Anshun|安顺|179","group":"A"},{"display":"安阳","data":"Anyang|安阳|181","group":"A"},{"display":"澳门","data":"Macau|澳门|59","group":"A"},{"display":"白城","data":"Baicheng|白城|1116","group":"B"},{"display":"百色","data":"Baise|百色|1140","group":"B"},{"display":"白沙","data":"baisha|白沙|21025","group":"B"},{"display":"白山","data":"baishan|白山|3886","group":"B"},{"display":"白银","data":"Baiyin|白银|1541","group":"B"},{"display":"保定","data":"Baoding|保定|185","group":"B"},{"display":"宝鸡","data":"Baoji|宝鸡|112","group":"B"},{"display":"保山","data":"Baoshan|保山|197","group":"B"},{"display":"保亭","data":"Baoting|保亭|54","group":"B"},{"display":"包头","data":"Baotou|包头|141","group":"B"},{"display":"巴彦淖尔","data":"Bayannaoer|巴彦淖尔|3887","group":"B"},{"display":"巴中","data":"bazhong|巴中|3966","group":"B"},{"display":"北海","data":"Beihai|北海|189","group":"B"},{"display":"北京","data":"Beijing|北京|1","group":"B"},{"display":"蚌埠","data":"Bengbu|蚌埠|182","group":"B"},{"display":"本溪","data":"Benxi|本溪|1155","group":"B"},{"display":"毕节","data":"bijie|毕节|22031","group":"B"},{"display":"滨州","data":"binzhou|滨州|1820","group":"B"},{"display":"博尔塔拉","data":"boertala|博尔塔拉|21468","group":"B"},{"display":"亳州","data":"Bozhou|亳州|1078","group":"B"},{"display":"昌江","data":"Cangjiang|昌江|56","group":"C"},{"display":"沧州","data":"Cangzhou|沧州|216","group":"C"},{"display":"长春","data":"Changchun|长春|158","group":"C"},{"display":"常德","data":"Changde|常德|201","group":"C"},{"display":"昌都","data":"Changdu|昌都|575","group":"C"},{"display":"昌吉","data":"changji|昌吉|22032","group":"C"},{"display":"长沙","data":"Changsha|长沙|206","group":"C"},{"display":"长治","data":"Changzhi|长治|137","group":"C"},{"display":"常州","data":"Changzhou|常州|213","group":"C"},{"display":"朝阳","data":"chaoyang|朝阳|211","group":"C"},{"display":"潮州","data":"Chaozhou|潮州|215","group":"C"},{"display":"承德","data":"Chengde|承德|562","group":"C"},{"display":"成都","data":"Chengdu|成都|28","group":"C"},{"display":"澄迈","data":"chengmai|澄迈|20836","group":"C"},{"display":"郴州","data":"Chenzhou|郴州|612","group":"C"},{"display":"嘉义","data":"CHIAYI|嘉义|5152","group":"C"},{"display":"赤峰","data":"Chifeng|赤峰|202","group":"C"},{"display":"池州","data":"Chizhou|池州|218","group":"C"},{"display":"重庆","data":"Chongqing|重庆|4","group":"C"},{"display":"崇左","data":"Chongzuo|崇左|1896","group":"C"},{"display":"滁州","data":"Chuzhou|滁州|214","group":"C"},{"display":"大理市","data":"Dali|大理市|36","group":"D"},{"display":"大连","data":"Dalian|大连|6","group":"D"},{"display":"丹东","data":"Dandong|丹东|221","group":"D"},{"display":"儋州","data":"Danzhou|儋州|57","group":"D"},{"display":"大庆","data":"Daqing|大庆|231","group":"D"},{"display":"大同","data":"Datong|大同|136","group":"D"},{"display":"大兴安岭","data":"Daxinganling|大兴安岭|7663","group":"D"},{"display":"达州","data":"Dazhou|达州|1233","group":"D"},{"display":"德阳","data":"Deyang|德阳|237","group":"D"},{"display":"德州","data":"Dezhou|德州|1370","group":"D"},{"display":"定安","data":"Ding'an|定安|50","group":"D"},{"display":"定西","data":"Dingxi|定西|1021","group":"D"},{"display":"东方","data":"Dongfang|东方|48","group":"D"},{"display":"东莞","data":"Dongguan|东莞|223","group":"D"},{"display":"东营","data":"Dongying|东营|236","group":"D"},{"display":"鄂尔多斯","data":"E'erduosi|鄂尔多斯|3976","group":"E"},{"display":"鄂州","data":"Ezhou|鄂州|992","group":"E"},{"display":"防城港","data":"Fangchenggang|防城港|1677","group":"F"},{"display":"佛山","data":"Foshan|佛山|251","group":"F"},{"display":"抚顺","data":"Fushun|抚顺|252","group":"F"},{"display":"阜新","data":"Fuxin|阜新|254","group":"F"},{"display":"阜阳","data":"Fuyang|阜阳|257","group":"F"},{"display":"福州","data":"Fuzhou|福州|258","group":"F"},{"display":"抚州","data":"Fuzhou|抚州|3884","group":"F"},{"display":"甘南","data":"Gannan|甘南|7844","group":"G"},{"display":"赣州","data":"Ganzhou|赣州|268","group":"G"},{"display":"甘孜","data":"ganzizhou|甘孜|4124","group":"G"},{"display":"高雄","data":"Gaoxiong|高雄|720","group":"G"},{"display":"广安","data":"Guang'an|广安|1100","group":"G"},{"display":"广元","data":"Guangyuan|广元|267","group":"G"},{"display":"广州","data":"Guangzhou|广州|32","group":"G"},{"display":"贵港","data":"Guigang|贵港|1518","group":"G"},{"display":"桂林","data":"Guilin|桂林|33","group":"G"},{"display":"贵阳","data":"Guiyang|贵阳|38","group":"G"},{"display":"固原","data":"Guyuan|固原|321","group":"G"},{"display":"哈尔滨","data":"Haerbin|哈尔滨|5","group":"H"},{"display":"海北","data":"Haibei|海北|7807","group":"H"},{"display":"海东","data":"Haidong|海东|7752","group":"H"},{"display":"海口","data":"Haikou|海口|42","group":"H"},{"display":"海西","data":"Haixizhou|海西|7589","group":"H"},{"display":"邯郸","data":"Handan|邯郸|275","group":"H"},{"display":"杭州","data":"Hangzhou|杭州|17","group":"H"},{"display":"汉中","data":"Hanzhong|汉中|129","group":"H"},{"display":"鹤壁","data":"Hebi|鹤壁|951","group":"H"},{"display":"河池","data":"hechi|河池|3969","group":"H"},{"display":"合肥","data":"Hefei|合肥|278","group":"H"},{"display":"鹤岗","data":"Hegang|鹤岗|1611","group":"H"},{"display":"黑河","data":"Heihe|黑河|281","group":"H"},{"display":"衡水","data":"Hengshui|衡水|290","group":"H"},{"display":"衡阳","data":"Hengyang|衡阳|297","group":"H"},{"display":"河源","data":"Heyuan|河源|693","group":"H"},{"display":"菏泽","data":"Heze|菏泽|1074","group":"H"},{"display":"贺州","data":"hezhou|贺州|4146","group":"H"},{"display":"香港","data":"Hong Kong|香港|58","group":"H"},{"display":"红河","data":"Honghezhou|红河|1341","group":"H"},{"display":"新竹","data":"Hsinchu|新竹|3845","group":"H"},{"display":"淮安","data":"Huai'an|淮安|577","group":"H"},{"display":"淮北","data":"Huaibei|淮北|272","group":"H"},{"display":"怀化","data":"Huaihua|怀化|282","group":"H"},{"display":"淮南","data":"Huainan|淮南|287","group":"H"},{"display":"花莲","data":"HUALIEN|花莲|6954","group":"H"},{"display":"黄冈","data":"Huanggang|黄冈|3885","group":"H"},{"display":"黄南","data":"Huangnan|黄南|7802","group":"H"},{"display":"黄山","data":"Huangshan|黄山|23","group":"H"},{"display":"黄石","data":"Huangshi|黄石|292","group":"H"},{"display":"呼和浩特","data":"Huhehaote|呼和浩特|103","group":"H"},{"display":"惠州","data":"Huizhou|惠州|299","group":"H"},{"display":"葫芦岛","data":"Huludao|葫芦岛|1050","group":"H"},{"display":"呼伦贝尔","data":"Hulunbeier|呼伦贝尔|4255","group":"H"},{"display":"湖州","data":"Huzhou|湖州|86","group":"H"},{"display":"佳木斯","data":"Jiamusi|佳木斯|317","group":"J"},{"display":"吉安","data":"Jian|吉安|933","group":"J"},{"display":"江门","data":"Jiangmen|江门|316","group":"J"},{"display":"焦作","data":"Jiaozuo|焦作|1093","group":"J"},{"display":"嘉兴","data":"Jiaxing|嘉兴|571","group":"J"},{"display":"嘉峪关","data":"Jiayuguan|嘉峪关|326","group":"J"},{"display":"揭阳","data":"Jieyang|揭阳|956","group":"J"},{"display":"吉林","data":"Jilin|吉林|159","group":"J"},{"display":"基隆","data":"Jilong|基隆|7810","group":"J"},{"display":"济南","data":"Jinan|济南|144","group":"J"},{"display":"金昌","data":"Jinchang|金昌|1158","group":"J"},{"display":"晋城","data":"Jincheng|晋城|1092","group":"J"},{"display":"景德镇","data":"Jingdezhen|景德镇|305","group":"J"},{"display":"荆门","data":"Jingmen|荆门|1121","group":"J"},{"display":"荆州","data":"Jingzhou|荆州|328","group":"J"},{"display":"金华","data":"Jinhua|金华|308","group":"J"},{"display":"济宁","data":"Jining|济宁|318","group":"J"},{"display":"晋中","data":"Jinzhong|晋中|1453","group":"J"},{"display":"锦州","data":"Jinzhou|锦州|327","group":"J"},{"display":"九江","data":"Jiujiang|九江|24","group":"J"},{"display":"酒泉","data":"Jiuquan|酒泉|662","group":"J"},{"display":"鸡西","data":"Jixi|鸡西|157","group":"J"},{"display":"济源","data":"Jiyuan|济源|1454","group":"J"},{"display":"开封","data":"Kaifeng|开封|331","group":"K"},{"display":"高雄","data":"Kaohsiung|高雄|720","group":"K"},{"display":"喀什","data":"kashi|喀什|21358","group":"K"},{"display":"克拉玛依","data":"Kelamayi|克拉玛依|166","group":"K"},{"display":"昆明","data":"Kunming|昆明|34","group":"K"},{"display":"来宾","data":"Laibin|来宾|1892","group":"L"},{"display":"莱芜","data":"Laiwu|莱芜|1452","group":"L"},{"display":"廊坊","data":"Langfang|廊坊|340","group":"L"},{"display":"兰州","data":"Lanzhou|兰州|100","group":"L"},{"display":"拉萨","data":"Lasa|拉萨|41","group":"L"},{"display":"乐东","data":"Ledong|乐东|49","group":"L"},{"display":"乐山","data":"Leshan|乐山|345","group":"L"},{"display":"凉山","data":"liangshanzhou|凉山|7537","group":"L"},{"display":"连云港","data":"Lianyungang|连云港|353","group":"L"},{"display":"聊城","data":"Liaocheng|聊城|1071","group":"L"},{"display":"辽阳","data":"Liaoyang|辽阳|351","group":"L"},{"display":"辽源","data":"Liaoyuan|辽源|352","group":"L"},{"display":"丽江","data":"Lijiang|丽江|37","group":"L"},{"display":"临沧","data":"Lincang|临沧|1236","group":"L"},{"display":"临汾","data":"Linfen|临汾|139","group":"L"},{"display":"临高","data":"lingao|临高|20868","group":"L"},{"display":"陵水","data":"Lingshui|陵水|55","group":"L"},{"display":"临夏","data":"linxia|临夏|21892","group":"L"},{"display":"临沂","data":"Linyi|临沂|569","group":"L"},{"display":"林芝","data":"Linzhi|林芝|108","group":"L"},{"display":"丽水","data":"Lishui|丽水|346","group":"L"},{"display":"六盘水","data":"Liupanshui|六盘水|605","group":"L"},{"display":"柳州","data":"Liuzhou|柳州|354","group":"L"},{"display":"陇南","data":"Longnan|陇南|7707","group":"L"},{"display":"龙岩","data":"Longyan|龙岩|348","group":"L"},{"display":"娄底","data":"Loudi|娄底|918","group":"L"},{"display":"六安","data":"Luan|六安|1705","group":"L"},{"display":"漯河","data":"Luohe|漯河|1088","group":"L"},{"display":"洛阳","data":"Luoyang|洛阳|350","group":"L"},{"display":"泸州","data":"Luzhou|泸州|355","group":"L"},{"display":"吕梁","data":"Lvliang|吕梁|7631","group":"L"},{"display":"马鞍山","data":"Ma'anshan|马鞍山|1024","group":"M"},{"display":"澳门","data":"Macau|澳门|59","group":"M"},{"display":"茂名","data":"Maoming|茂名|1105","group":"M"},{"display":"眉山","data":"Meishan|眉山|1148","group":"M"},{"display":"梅州","data":"Meizhou|梅州|3053","group":"M"},{"display":"绵阳","data":"Mianyang|绵阳|370","group":"M"},{"display":"牡丹江","data":"Mudanjiang|牡丹江|150","group":"M"},{"display":"南昌","data":"Nanchang|南昌|376","group":"N"},{"display":"南充","data":"Nanchong|南充|377","group":"N"},{"display":"南京","data":"Nanjing|南京|12","group":"N"},{"display":"南宁","data":"Nanning|南宁|380","group":"N"},{"display":"南平","data":"Nanping|南平|606","group":"N"},{"display":"南通","data":"Nantong|南通|82","group":"N"},{"display":"南阳","data":"Nanyang|南阳|385","group":"N"},{"display":"那曲","data":"naqu|那曲|3839","group":"N"},{"display":"内江","data":"Neijiang|内江|1597","group":"N"},{"display":"宁波","data":"Ningbo|宁波|375","group":"N"},{"display":"宁德","data":"Ningde|宁德|378","group":"N"},{"display":"盘锦","data":"Panjin|盘锦|387","group":"P"},{"display":"攀枝花","data":"Panzhihua|攀枝花|1097","group":"P"},{"display":"澎湖","data":"Penghu|澎湖|7805","group":"P"},{"display":"平顶山","data":"pingdingshan|平顶山|3222","group":"P"},{"display":"平凉","data":"Pingliang|平凉|388","group":"P"},{"display":"屏东","data":"PINGTUNG|屏东|5589","group":"P"},{"display":"萍乡","data":"Pingxiang|萍乡|1840","group":"P"},{"display":"普洱","data":"Puer|普洱|3996","group":"P"},{"display":"莆田","data":"Putian|莆田|667","group":"P"},{"display":"濮阳","data":"Puyang|濮阳|1232","group":"P"},{"display":"黔东南","data":"qiandongnan|黔东南|21778","group":"Q"},{"display":"黔南","data":"qiannan|黔南|21179","group":"Q"},{"display":"青岛","data":"Qingdao|青岛|7","group":"Q"},{"display":"庆阳","data":"Qingyang|庆阳|404","group":"Q"},{"display":"清远","data":"Qingyuan|清远|1422","group":"Q"},{"display":"秦皇岛","data":"Qinhuangdao|秦皇岛|147","group":"Q"},{"display":"钦州","data":"Qinzhou|钦州|1899","group":"Q"},{"display":"琼海","data":"Qionghai|琼海|52","group":"Q"},{"display":"琼中","data":"Qiongzhong|琼中|53","group":"Q"},{"display":"齐齐哈尔","data":"Qiqihaer|齐齐哈尔|149","group":"Q"},{"display":"七台河","data":"Qitaihe|七台河|1599","group":"Q"},{"display":"泉州","data":"Quanzhou|泉州|406","group":"Q"},{"display":"曲靖","data":"Qujing|曲靖|985","group":"Q"},{"display":"衢州","data":"Quzhou|衢州|407","group":"Q"},{"display":"日喀则","data":"Rikaze|日喀则|92","group":"R"},{"display":"日照","data":"Rizhao|日照|1106","group":"R"},{"display":"三门峡","data":"Sanmenxia|三门峡|436","group":"S"},{"display":"三明","data":"Sanming|三明|437","group":"S"},{"display":"三亚","data":"Sanya|三亚|43","group":"S"},{"display":"上海","data":"Shanghai|上海|2","group":"S"},{"display":"商洛","data":"Shangluo|商洛|7551","group":"S"},{"display":"商丘","data":"Shangqiu|商丘|441","group":"S"},{"display":"上饶","data":"Shangrao|上饶|411","group":"S"},{"display":"汕头","data":"Shantou|汕头|447","group":"S"},{"display":"汕尾","data":"Shanwei|汕尾|1436","group":"S"},{"display":"韶关","data":"Shaoguan|韶关|422","group":"S"},{"display":"绍兴","data":"Shaoxing|绍兴|22","group":"S"},{"display":"邵阳","data":"Shaoyang|邵阳|1111","group":"S"},{"display":"沈阳","data":"Shenyang|沈阳|451","group":"S"},{"display":"深圳","data":"Shenzhen|深圳|30","group":"S"},{"display":"石家庄","data":"Shijiazhuang|石家庄|428","group":"S"},{"display":"十堰","data":"SHIYAN|十堰|452","group":"S"},{"display":"石嘴山","data":"shizuishan|石嘴山|4216","group":"S"},{"display":"双鸭山","data":"Shuangyashan|双鸭山|1617","group":"S"},{"display":"朔州","data":"Shuozhou|朔州|1317","group":"S"},{"display":"四平","data":"Siping|四平|440","group":"S"},{"display":"松原","data":"Songyuan|松原|1303","group":"S"},{"display":"绥化","data":"Suihua|绥化|1128","group":"S"},{"display":"遂宁","data":"Suining|遂宁|1371","group":"S"},{"display":"随州","data":"Suizhou|随州|1117","group":"S"},{"display":"宿迁","data":"Suqian|宿迁|1472","group":"S"},{"display":"宿州","data":"Suzhou|宿州|521","group":"S"},{"display":"苏州","data":"Suzhou|苏州|14","group":"S"},{"display":"塔城","data":"Tacheng|塔城|455","group":"T"},{"display":"泰安","data":"Taian|泰安|454","group":"T"},{"display":"台中","data":"Taichung|台中|3849","group":"T"},{"display":"台南","data":"Tainan|台南|3847","group":"T"},{"display":"台北","data":"Taipei|台北|617","group":"T"},{"display":"太原","data":"Taiyuan|太原|105","group":"T"},{"display":"泰州","data":"Taizhou|泰州|579","group":"T"},{"display":"台州","data":"Taizhou|台州|578","group":"T"},{"display":"唐山","data":"Tangshan|唐山|468","group":"T"},{"display":"桃园市","data":"Taoyuan|桃园市|7570","group":"T"},{"display":"天津","data":"Tianjin|天津|3","group":"T"},{"display":"天水","data":"Tianshui|天水|464","group":"T"},{"display":"铁岭","data":"Tieling|铁岭|1048","group":"T"},{"display":"铜川","data":"Tongchuan|铜川|118","group":"T"},{"display":"通化","data":"Tonghua|通化|456","group":"T"},{"display":"通辽","data":"Tongliao|通辽|458","group":"T"},{"display":"铜陵","data":"Tongling|铜陵|459","group":"T"},{"display":"铜仁","data":"tongren|铜仁|22033","group":"T"},{"display":"屯昌","data":"Tunchang|屯昌|47","group":"T"},{"display":"乌兰察布","data":"ULANQAB|乌兰察布|7518","group":"U"},{"display":"万宁","data":"Wanning|万宁|45","group":"W"},{"display":"潍坊","data":"Weifang|潍坊|475","group":"W"},{"display":"威海","data":"Weihai|威海|479","group":"W"},{"display":"渭南","data":"Weinan|渭南|1030","group":"W"},{"display":"文昌","data":"Wenchang|文昌|44","group":"W"},{"display":"温州","data":"Wenzhou|温州|491","group":"W"},{"display":"乌海","data":"Wuhai|乌海|1133","group":"W"},{"display":"武汉","data":"Wuhan|武汉|477","group":"W"},{"display":"芜湖","data":"Wuhu|芜湖|478","group":"W"},{"display":"乌鲁木齐","data":"Wulumuqi|乌鲁木齐|39","group":"W"},{"display":"武威","data":"Wuwei|武威|664","group":"W"},{"display":"无锡","data":"Wuxi|无锡|13","group":"W"},{"display":"五指山","data":"Wuzhishan|五指山|46","group":"W"},{"display":"吴忠","data":"wuzhong|吴忠|7587","group":"W"},{"display":"梧州","data":"Wuzhou|梧州|492","group":"W"},{"display":"厦门","data":"Xiamen|厦门|25","group":"X"},{"display":"西安","data":"Xian|西安|10","group":"X"},{"display":"香港","data":"Hong Kong|香港|58","group":"X"},{"display":"湘潭","data":"Xiangtan|湘潭|598","group":"X"},{"display":"湘西","data":"xiangxi|湘西|3910","group":"X"},{"display":"襄阳","data":"Xiangyang|襄阳|496","group":"X"},{"display":"咸宁","data":"Xianning|咸宁|937","group":"X"},{"display":"咸阳","data":"Xianyang|咸阳|111","group":"X"},{"display":"孝感","data":"Xiaogan|孝感|1490","group":"X"},{"display":"锡林郭勒盟","data":"Xilinguole|锡林郭勒盟|7576","group":"X"},{"display":"新北","data":"Xinbeishi|新北|7662","group":"X"},{"display":"兴安盟","data":"xinganmeng|兴安盟|21021","group":"X"},{"display":"邢台","data":"Xingtai|邢台|947","group":"X"},{"display":"西宁","data":"Xining|西宁|124","group":"X"},{"display":"新乡","data":"Xinxiang|新乡|507","group":"X"},{"display":"信阳","data":"Xinyang|信阳|510","group":"X"},{"display":"新余","data":"Xinyu|新余|603","group":"X"},{"display":"忻州","data":"Xinzhou|忻州|513","group":"X"},{"display":"宣城","data":"Xuancheng|宣城|1006","group":"X"},{"display":"许昌","data":"Xuchang|许昌|1094","group":"X"},{"display":"徐州","data":"Xuzhou|徐州|512","group":"X"},{"display":"雅安","data":"yaan|雅安|3277","group":"Y"},{"display":"延安","data":"Yan'an|延安|110","group":"Y"},{"display":"盐城","data":"Yancheng|盐城|1200","group":"Y"},{"display":"阳江","data":"Yangjiang|阳江|692","group":"Y"},{"display":"阳泉","data":"Yangquan|阳泉|907","group":"Y"},{"display":"扬州","data":"Yangzhou|扬州|15","group":"Y"},{"display":"烟台","data":"Yantai|烟台|533","group":"Y"},{"display":"宜宾","data":"Yibin|宜宾|514","group":"Y"},{"display":"宜昌","data":"Yichang|宜昌|515","group":"Y"},{"display":"伊春","data":"Yichun|伊春|517","group":"Y"},{"display":"宜春","data":"Yichun|宜春|518","group":"Y"},{"display":"伊犁","data":"Yili|伊犁|98","group":"Y"},{"display":"银川","data":"Yinchuan|银川|99","group":"Y"},{"display":"营口","data":"Yingkou|营口|1300","group":"Y"},{"display":"鹰潭","data":"Yingtan|鹰潭|534","group":"Y"},{"display":"益阳","data":"Yiyang|益阳|1125","group":"Y"},{"display":"永州","data":"Yongzhou|永州|970","group":"Y"},{"display":"岳阳","data":"Yueyang|岳阳|539","group":"Y"},{"display":"玉林","data":"Yulin|玉林|1113","group":"Y"},{"display":"榆林","data":"Yulin|榆林|527","group":"Y"},{"display":"运城","data":"Yuncheng|运城|140","group":"Y"},{"display":"云浮","data":"yunfu|云浮|3933","group":"Y"},{"display":"云林市","data":"yunlin|云林市|7523","group":"Y"},{"display":"玉溪","data":"Yuxi|玉溪|186","group":"Y"},{"display":"枣庄","data":"Zaozhuang|枣庄|614","group":"Z"},{"display":"张家界","data":"Zhangjiajie|张家界|27","group":"Z"},{"display":"张家口","data":"Zhangjiakou|张家口|550","group":"Z"},{"display":"张掖","data":"Zhangye|张掖|663","group":"Z"},{"display":"漳州","data":"Zhangzhou|漳州|560","group":"Z"},{"display":"湛江","data":"Zhanjiang|湛江|547","group":"Z"},{"display":"肇庆","data":"Zhaoqing|肇庆|552","group":"Z"},{"display":"昭通","data":"Zhaotong|昭通|555","group":"Z"},{"display":"郑州","data":"Zhengzhou|郑州|559","group":"Z"},{"display":"镇江","data":"Zhenjiang|镇江|16","group":"Z"},{"display":"中山","data":"Zhongshan|中山|553","group":"Z"},{"display":"中卫","data":"Zhongwei|中卫|556","group":"Z"},{"display":"周口","data":"zhoukou|周口|3221","group":"Z"},{"display":"舟山","data":"Zhoushan|舟山|19","group":"Z"},{"display":"珠海","data":"Zhuhai|珠海|31","group":"Z"},{"display":"驻马店","data":"Zhumadian|驻马店|551","group":"Z"},{"display":"株洲","data":"Zhuzhou|株洲|601","group":"Z"},{"display":"淄博","data":"Zibo|淄博|542","group":"Z"},{"display":"自贡","data":"Zigong|自贡|544","group":"Z"},{"display":"资阳","data":"Ziyang|资阳|1560","group":"Z"},{"display":"遵义","data":"Zunyi|遵义|558","group":"Z"}];
    for city in ctripCity:
        cityName = city['display'];
        cityId = city['data'].split('|')[2];
        #print('cityName=' + cityName + ',cityId='+ cityId);
        #设置请求参数
        keyword = '青年旅舍';
        today = datetime.datetime.now().strftime('%Y-%m-%d');
        param = {'page':1,'cityId':cityId,'keyword':keyword, 'k1':keyword, 'txtkeyword' : keyword,'cityName':cityName,'StartTime':today,'DepTime':today};
        param['__VIEWSTATEGENERATOR'] = 'DB1FBB6D';
        param['operationtype'] = 'NEWHOTELORDER';
        param['IsOnlyAirHotel'] = 'F';
        param['OrderBy'] = 99;
        param['IsCanReserve'] = 'F';
        param['prepay'] = 'F';
        param['promotion'] = 'F';
        param['priceRange'] = -2;
        param['htlPageView'] = 0;
        param['hotelType'] = 'F';
        param['hasPKGHotel'] = 'F';
        param['requestTravelMoney'] = 'F';
        param['isusergiftcard'] = 'F';
        param['useFG'] = 'F';
        param['htlFrom'] = 'hotellist';
        param['isHuaZhu'] = 'False';
        param['HideIsNoneLogin'] = 'T';
        param['isfromlist'] = 'T';
        param['ubt_price_key'] = 'htl_search_result_promotion';

        for i in range(5):
            hotelList = fetchHotelUrl(param);
            if hotelList is not None :
                saveHotelList(hotelList);
            print('从携程官网分页获取'+cityName +'的青旅列表成功!');

'''
从携程官网获取每个青旅的所有详细信息并入库
'''
def fetHotelInfosFromCtrip():
    ctripCity = [{"display":"北京","data":"Beijing|北京|1","group":"B"},{"display":"上海","data":"Shanghai|上海|2","group":"S"},{"display":"天津","data":"Tianjin|天津|3","group":"T"},{"display":"重庆","data":"Chongqing|重庆|4","group":"C"},{"display":"大连","data":"Dalian|大连|6","group":"D"},{"display":"青岛","data":"Qingdao|青岛|7","group":"Q"},{"display":"西安","data":"Xian|西安|10","group":"X"},{"display":"南京","data":"Nanjing|南京|12","group":"N"},{"display":"苏州","data":"Suzhou|苏州|14","group":"S"},{"display":"杭州","data":"Hangzhou|杭州|17","group":"H"},{"display":"厦门","data":"Xiamen|厦门|25","group":"X"},{"display":"成都","data":"Chengdu|成都|28","group":"C"},{"display":"深圳","data":"Shenzhen|深圳|30","group":"S"},{"display":"广州","data":"Guangzhou|广州|32","group":"G"},{"display":"三亚","data":"Sanya|三亚|43","group":"S"},{"display":"台北","data":"Taipei|台北|617","group":"T"},{"display":"香港","data":"Hong Kong|香港|58","group":"H"},{"display":"济南","data":"Jinan|济南|144","group":"J"},{"display":"宁波","data":"Ningbo|宁波|375","group":"N"},{"display":"沈阳","data":"Shenyang|沈阳|451","group":"S"},{"display":"武汉","data":"Wuhan|武汉|477","group":"W"},{"display":"阿坝","data":"abazhou|阿坝|1838","group":"A"},{"display":"阿克苏","data":"Akesu|阿克苏|173","group":"A"},{"display":"阿勒泰","data":"Aletai|阿勒泰|175","group":"A"},{"display":"阿里","data":"Ali|阿里|97","group":"A"},{"display":"安康","data":"Ankang|安康|171","group":"A"},{"display":"安庆","data":"Anqing|安庆|177","group":"A"},{"display":"鞍山","data":"Anshan|鞍山|178","group":"A"},{"display":"安顺","data":"Anshun|安顺|179","group":"A"},{"display":"安阳","data":"Anyang|安阳|181","group":"A"},{"display":"澳门","data":"Macau|澳门|59","group":"A"},{"display":"白城","data":"Baicheng|白城|1116","group":"B"},{"display":"百色","data":"Baise|百色|1140","group":"B"},{"display":"白沙","data":"baisha|白沙|21025","group":"B"},{"display":"白山","data":"baishan|白山|3886","group":"B"},{"display":"白银","data":"Baiyin|白银|1541","group":"B"},{"display":"保定","data":"Baoding|保定|185","group":"B"},{"display":"宝鸡","data":"Baoji|宝鸡|112","group":"B"},{"display":"保山","data":"Baoshan|保山|197","group":"B"},{"display":"保亭","data":"Baoting|保亭|54","group":"B"},{"display":"包头","data":"Baotou|包头|141","group":"B"},{"display":"巴彦淖尔","data":"Bayannaoer|巴彦淖尔|3887","group":"B"},{"display":"巴中","data":"bazhong|巴中|3966","group":"B"},{"display":"北海","data":"Beihai|北海|189","group":"B"},{"display":"北京","data":"Beijing|北京|1","group":"B"},{"display":"蚌埠","data":"Bengbu|蚌埠|182","group":"B"},{"display":"本溪","data":"Benxi|本溪|1155","group":"B"},{"display":"毕节","data":"bijie|毕节|22031","group":"B"},{"display":"滨州","data":"binzhou|滨州|1820","group":"B"},{"display":"博尔塔拉","data":"boertala|博尔塔拉|21468","group":"B"},{"display":"亳州","data":"Bozhou|亳州|1078","group":"B"},{"display":"昌江","data":"Cangjiang|昌江|56","group":"C"},{"display":"沧州","data":"Cangzhou|沧州|216","group":"C"},{"display":"长春","data":"Changchun|长春|158","group":"C"},{"display":"常德","data":"Changde|常德|201","group":"C"},{"display":"昌都","data":"Changdu|昌都|575","group":"C"},{"display":"昌吉","data":"changji|昌吉|22032","group":"C"},{"display":"长沙","data":"Changsha|长沙|206","group":"C"},{"display":"长治","data":"Changzhi|长治|137","group":"C"},{"display":"常州","data":"Changzhou|常州|213","group":"C"},{"display":"朝阳","data":"chaoyang|朝阳|211","group":"C"},{"display":"潮州","data":"Chaozhou|潮州|215","group":"C"},{"display":"承德","data":"Chengde|承德|562","group":"C"},{"display":"成都","data":"Chengdu|成都|28","group":"C"},{"display":"澄迈","data":"chengmai|澄迈|20836","group":"C"},{"display":"郴州","data":"Chenzhou|郴州|612","group":"C"},{"display":"嘉义","data":"CHIAYI|嘉义|5152","group":"C"},{"display":"赤峰","data":"Chifeng|赤峰|202","group":"C"},{"display":"池州","data":"Chizhou|池州|218","group":"C"},{"display":"重庆","data":"Chongqing|重庆|4","group":"C"},{"display":"崇左","data":"Chongzuo|崇左|1896","group":"C"},{"display":"滁州","data":"Chuzhou|滁州|214","group":"C"},{"display":"大理市","data":"Dali|大理市|36","group":"D"},{"display":"大连","data":"Dalian|大连|6","group":"D"},{"display":"丹东","data":"Dandong|丹东|221","group":"D"},{"display":"儋州","data":"Danzhou|儋州|57","group":"D"},{"display":"大庆","data":"Daqing|大庆|231","group":"D"},{"display":"大同","data":"Datong|大同|136","group":"D"},{"display":"大兴安岭","data":"Daxinganling|大兴安岭|7663","group":"D"},{"display":"达州","data":"Dazhou|达州|1233","group":"D"},{"display":"德阳","data":"Deyang|德阳|237","group":"D"},{"display":"德州","data":"Dezhou|德州|1370","group":"D"},{"display":"定安","data":"Ding'an|定安|50","group":"D"},{"display":"定西","data":"Dingxi|定西|1021","group":"D"},{"display":"东方","data":"Dongfang|东方|48","group":"D"},{"display":"东莞","data":"Dongguan|东莞|223","group":"D"},{"display":"东营","data":"Dongying|东营|236","group":"D"},{"display":"鄂尔多斯","data":"E'erduosi|鄂尔多斯|3976","group":"E"},{"display":"鄂州","data":"Ezhou|鄂州|992","group":"E"},{"display":"防城港","data":"Fangchenggang|防城港|1677","group":"F"},{"display":"佛山","data":"Foshan|佛山|251","group":"F"},{"display":"抚顺","data":"Fushun|抚顺|252","group":"F"},{"display":"阜新","data":"Fuxin|阜新|254","group":"F"},{"display":"阜阳","data":"Fuyang|阜阳|257","group":"F"},{"display":"福州","data":"Fuzhou|福州|258","group":"F"},{"display":"抚州","data":"Fuzhou|抚州|3884","group":"F"},{"display":"甘南","data":"Gannan|甘南|7844","group":"G"},{"display":"赣州","data":"Ganzhou|赣州|268","group":"G"},{"display":"甘孜","data":"ganzizhou|甘孜|4124","group":"G"},{"display":"高雄","data":"Gaoxiong|高雄|720","group":"G"},{"display":"广安","data":"Guang'an|广安|1100","group":"G"},{"display":"广元","data":"Guangyuan|广元|267","group":"G"},{"display":"广州","data":"Guangzhou|广州|32","group":"G"},{"display":"贵港","data":"Guigang|贵港|1518","group":"G"},{"display":"桂林","data":"Guilin|桂林|33","group":"G"},{"display":"贵阳","data":"Guiyang|贵阳|38","group":"G"},{"display":"固原","data":"Guyuan|固原|321","group":"G"},{"display":"哈尔滨","data":"Haerbin|哈尔滨|5","group":"H"},{"display":"海北","data":"Haibei|海北|7807","group":"H"},{"display":"海东","data":"Haidong|海东|7752","group":"H"},{"display":"海口","data":"Haikou|海口|42","group":"H"},{"display":"海西","data":"Haixizhou|海西|7589","group":"H"},{"display":"邯郸","data":"Handan|邯郸|275","group":"H"},{"display":"杭州","data":"Hangzhou|杭州|17","group":"H"},{"display":"汉中","data":"Hanzhong|汉中|129","group":"H"},{"display":"鹤壁","data":"Hebi|鹤壁|951","group":"H"},{"display":"河池","data":"hechi|河池|3969","group":"H"},{"display":"合肥","data":"Hefei|合肥|278","group":"H"},{"display":"鹤岗","data":"Hegang|鹤岗|1611","group":"H"},{"display":"黑河","data":"Heihe|黑河|281","group":"H"},{"display":"衡水","data":"Hengshui|衡水|290","group":"H"},{"display":"衡阳","data":"Hengyang|衡阳|297","group":"H"},{"display":"河源","data":"Heyuan|河源|693","group":"H"},{"display":"菏泽","data":"Heze|菏泽|1074","group":"H"},{"display":"贺州","data":"hezhou|贺州|4146","group":"H"},{"display":"香港","data":"Hong Kong|香港|58","group":"H"},{"display":"红河","data":"Honghezhou|红河|1341","group":"H"},{"display":"新竹","data":"Hsinchu|新竹|3845","group":"H"},{"display":"淮安","data":"Huai'an|淮安|577","group":"H"},{"display":"淮北","data":"Huaibei|淮北|272","group":"H"},{"display":"怀化","data":"Huaihua|怀化|282","group":"H"},{"display":"淮南","data":"Huainan|淮南|287","group":"H"},{"display":"花莲","data":"HUALIEN|花莲|6954","group":"H"},{"display":"黄冈","data":"Huanggang|黄冈|3885","group":"H"},{"display":"黄南","data":"Huangnan|黄南|7802","group":"H"},{"display":"黄山","data":"Huangshan|黄山|23","group":"H"},{"display":"黄石","data":"Huangshi|黄石|292","group":"H"},{"display":"呼和浩特","data":"Huhehaote|呼和浩特|103","group":"H"},{"display":"惠州","data":"Huizhou|惠州|299","group":"H"},{"display":"葫芦岛","data":"Huludao|葫芦岛|1050","group":"H"},{"display":"呼伦贝尔","data":"Hulunbeier|呼伦贝尔|4255","group":"H"},{"display":"湖州","data":"Huzhou|湖州|86","group":"H"},{"display":"佳木斯","data":"Jiamusi|佳木斯|317","group":"J"},{"display":"吉安","data":"Jian|吉安|933","group":"J"},{"display":"江门","data":"Jiangmen|江门|316","group":"J"},{"display":"焦作","data":"Jiaozuo|焦作|1093","group":"J"},{"display":"嘉兴","data":"Jiaxing|嘉兴|571","group":"J"},{"display":"嘉峪关","data":"Jiayuguan|嘉峪关|326","group":"J"},{"display":"揭阳","data":"Jieyang|揭阳|956","group":"J"},{"display":"吉林","data":"Jilin|吉林|159","group":"J"},{"display":"基隆","data":"Jilong|基隆|7810","group":"J"},{"display":"济南","data":"Jinan|济南|144","group":"J"},{"display":"金昌","data":"Jinchang|金昌|1158","group":"J"},{"display":"晋城","data":"Jincheng|晋城|1092","group":"J"},{"display":"景德镇","data":"Jingdezhen|景德镇|305","group":"J"},{"display":"荆门","data":"Jingmen|荆门|1121","group":"J"},{"display":"荆州","data":"Jingzhou|荆州|328","group":"J"},{"display":"金华","data":"Jinhua|金华|308","group":"J"},{"display":"济宁","data":"Jining|济宁|318","group":"J"},{"display":"晋中","data":"Jinzhong|晋中|1453","group":"J"},{"display":"锦州","data":"Jinzhou|锦州|327","group":"J"},{"display":"九江","data":"Jiujiang|九江|24","group":"J"},{"display":"酒泉","data":"Jiuquan|酒泉|662","group":"J"},{"display":"鸡西","data":"Jixi|鸡西|157","group":"J"},{"display":"济源","data":"Jiyuan|济源|1454","group":"J"},{"display":"开封","data":"Kaifeng|开封|331","group":"K"},{"display":"高雄","data":"Kaohsiung|高雄|720","group":"K"},{"display":"喀什","data":"kashi|喀什|21358","group":"K"},{"display":"克拉玛依","data":"Kelamayi|克拉玛依|166","group":"K"},{"display":"昆明","data":"Kunming|昆明|34","group":"K"},{"display":"来宾","data":"Laibin|来宾|1892","group":"L"},{"display":"莱芜","data":"Laiwu|莱芜|1452","group":"L"},{"display":"廊坊","data":"Langfang|廊坊|340","group":"L"},{"display":"兰州","data":"Lanzhou|兰州|100","group":"L"},{"display":"拉萨","data":"Lasa|拉萨|41","group":"L"},{"display":"乐东","data":"Ledong|乐东|49","group":"L"},{"display":"乐山","data":"Leshan|乐山|345","group":"L"},{"display":"凉山","data":"liangshanzhou|凉山|7537","group":"L"},{"display":"连云港","data":"Lianyungang|连云港|353","group":"L"},{"display":"聊城","data":"Liaocheng|聊城|1071","group":"L"},{"display":"辽阳","data":"Liaoyang|辽阳|351","group":"L"},{"display":"辽源","data":"Liaoyuan|辽源|352","group":"L"},{"display":"丽江","data":"Lijiang|丽江|37","group":"L"},{"display":"临沧","data":"Lincang|临沧|1236","group":"L"},{"display":"临汾","data":"Linfen|临汾|139","group":"L"},{"display":"临高","data":"lingao|临高|20868","group":"L"},{"display":"陵水","data":"Lingshui|陵水|55","group":"L"},{"display":"临夏","data":"linxia|临夏|21892","group":"L"},{"display":"临沂","data":"Linyi|临沂|569","group":"L"},{"display":"林芝","data":"Linzhi|林芝|108","group":"L"},{"display":"丽水","data":"Lishui|丽水|346","group":"L"},{"display":"六盘水","data":"Liupanshui|六盘水|605","group":"L"},{"display":"柳州","data":"Liuzhou|柳州|354","group":"L"},{"display":"陇南","data":"Longnan|陇南|7707","group":"L"},{"display":"龙岩","data":"Longyan|龙岩|348","group":"L"},{"display":"娄底","data":"Loudi|娄底|918","group":"L"},{"display":"六安","data":"Luan|六安|1705","group":"L"},{"display":"漯河","data":"Luohe|漯河|1088","group":"L"},{"display":"洛阳","data":"Luoyang|洛阳|350","group":"L"},{"display":"泸州","data":"Luzhou|泸州|355","group":"L"},{"display":"吕梁","data":"Lvliang|吕梁|7631","group":"L"},{"display":"马鞍山","data":"Ma'anshan|马鞍山|1024","group":"M"},{"display":"澳门","data":"Macau|澳门|59","group":"M"},{"display":"茂名","data":"Maoming|茂名|1105","group":"M"},{"display":"眉山","data":"Meishan|眉山|1148","group":"M"},{"display":"梅州","data":"Meizhou|梅州|3053","group":"M"},{"display":"绵阳","data":"Mianyang|绵阳|370","group":"M"},{"display":"牡丹江","data":"Mudanjiang|牡丹江|150","group":"M"},{"display":"南昌","data":"Nanchang|南昌|376","group":"N"},{"display":"南充","data":"Nanchong|南充|377","group":"N"},{"display":"南京","data":"Nanjing|南京|12","group":"N"},{"display":"南宁","data":"Nanning|南宁|380","group":"N"},{"display":"南平","data":"Nanping|南平|606","group":"N"},{"display":"南通","data":"Nantong|南通|82","group":"N"},{"display":"南阳","data":"Nanyang|南阳|385","group":"N"},{"display":"那曲","data":"naqu|那曲|3839","group":"N"},{"display":"内江","data":"Neijiang|内江|1597","group":"N"},{"display":"宁波","data":"Ningbo|宁波|375","group":"N"},{"display":"宁德","data":"Ningde|宁德|378","group":"N"},{"display":"盘锦","data":"Panjin|盘锦|387","group":"P"},{"display":"攀枝花","data":"Panzhihua|攀枝花|1097","group":"P"},{"display":"澎湖","data":"Penghu|澎湖|7805","group":"P"},{"display":"平顶山","data":"pingdingshan|平顶山|3222","group":"P"},{"display":"平凉","data":"Pingliang|平凉|388","group":"P"},{"display":"屏东","data":"PINGTUNG|屏东|5589","group":"P"},{"display":"萍乡","data":"Pingxiang|萍乡|1840","group":"P"},{"display":"普洱","data":"Puer|普洱|3996","group":"P"},{"display":"莆田","data":"Putian|莆田|667","group":"P"},{"display":"濮阳","data":"Puyang|濮阳|1232","group":"P"},{"display":"黔东南","data":"qiandongnan|黔东南|21778","group":"Q"},{"display":"黔南","data":"qiannan|黔南|21179","group":"Q"},{"display":"青岛","data":"Qingdao|青岛|7","group":"Q"},{"display":"庆阳","data":"Qingyang|庆阳|404","group":"Q"},{"display":"清远","data":"Qingyuan|清远|1422","group":"Q"},{"display":"秦皇岛","data":"Qinhuangdao|秦皇岛|147","group":"Q"},{"display":"钦州","data":"Qinzhou|钦州|1899","group":"Q"},{"display":"琼海","data":"Qionghai|琼海|52","group":"Q"},{"display":"琼中","data":"Qiongzhong|琼中|53","group":"Q"},{"display":"齐齐哈尔","data":"Qiqihaer|齐齐哈尔|149","group":"Q"},{"display":"七台河","data":"Qitaihe|七台河|1599","group":"Q"},{"display":"泉州","data":"Quanzhou|泉州|406","group":"Q"},{"display":"曲靖","data":"Qujing|曲靖|985","group":"Q"},{"display":"衢州","data":"Quzhou|衢州|407","group":"Q"},{"display":"日喀则","data":"Rikaze|日喀则|92","group":"R"},{"display":"日照","data":"Rizhao|日照|1106","group":"R"},{"display":"三门峡","data":"Sanmenxia|三门峡|436","group":"S"},{"display":"三明","data":"Sanming|三明|437","group":"S"},{"display":"三亚","data":"Sanya|三亚|43","group":"S"},{"display":"上海","data":"Shanghai|上海|2","group":"S"},{"display":"商洛","data":"Shangluo|商洛|7551","group":"S"},{"display":"商丘","data":"Shangqiu|商丘|441","group":"S"},{"display":"上饶","data":"Shangrao|上饶|411","group":"S"},{"display":"汕头","data":"Shantou|汕头|447","group":"S"},{"display":"汕尾","data":"Shanwei|汕尾|1436","group":"S"},{"display":"韶关","data":"Shaoguan|韶关|422","group":"S"},{"display":"绍兴","data":"Shaoxing|绍兴|22","group":"S"},{"display":"邵阳","data":"Shaoyang|邵阳|1111","group":"S"},{"display":"沈阳","data":"Shenyang|沈阳|451","group":"S"},{"display":"深圳","data":"Shenzhen|深圳|30","group":"S"},{"display":"石家庄","data":"Shijiazhuang|石家庄|428","group":"S"},{"display":"十堰","data":"SHIYAN|十堰|452","group":"S"},{"display":"石嘴山","data":"shizuishan|石嘴山|4216","group":"S"},{"display":"双鸭山","data":"Shuangyashan|双鸭山|1617","group":"S"},{"display":"朔州","data":"Shuozhou|朔州|1317","group":"S"},{"display":"四平","data":"Siping|四平|440","group":"S"},{"display":"松原","data":"Songyuan|松原|1303","group":"S"},{"display":"绥化","data":"Suihua|绥化|1128","group":"S"},{"display":"遂宁","data":"Suining|遂宁|1371","group":"S"},{"display":"随州","data":"Suizhou|随州|1117","group":"S"},{"display":"宿迁","data":"Suqian|宿迁|1472","group":"S"},{"display":"宿州","data":"Suzhou|宿州|521","group":"S"},{"display":"苏州","data":"Suzhou|苏州|14","group":"S"},{"display":"塔城","data":"Tacheng|塔城|455","group":"T"},{"display":"泰安","data":"Taian|泰安|454","group":"T"},{"display":"台中","data":"Taichung|台中|3849","group":"T"},{"display":"台南","data":"Tainan|台南|3847","group":"T"},{"display":"台北","data":"Taipei|台北|617","group":"T"},{"display":"太原","data":"Taiyuan|太原|105","group":"T"},{"display":"泰州","data":"Taizhou|泰州|579","group":"T"},{"display":"台州","data":"Taizhou|台州|578","group":"T"},{"display":"唐山","data":"Tangshan|唐山|468","group":"T"},{"display":"桃园市","data":"Taoyuan|桃园市|7570","group":"T"},{"display":"天津","data":"Tianjin|天津|3","group":"T"},{"display":"天水","data":"Tianshui|天水|464","group":"T"},{"display":"铁岭","data":"Tieling|铁岭|1048","group":"T"},{"display":"铜川","data":"Tongchuan|铜川|118","group":"T"},{"display":"通化","data":"Tonghua|通化|456","group":"T"},{"display":"通辽","data":"Tongliao|通辽|458","group":"T"},{"display":"铜陵","data":"Tongling|铜陵|459","group":"T"},{"display":"铜仁","data":"tongren|铜仁|22033","group":"T"},{"display":"屯昌","data":"Tunchang|屯昌|47","group":"T"},{"display":"乌兰察布","data":"ULANQAB|乌兰察布|7518","group":"U"},{"display":"万宁","data":"Wanning|万宁|45","group":"W"},{"display":"潍坊","data":"Weifang|潍坊|475","group":"W"},{"display":"威海","data":"Weihai|威海|479","group":"W"},{"display":"渭南","data":"Weinan|渭南|1030","group":"W"},{"display":"文昌","data":"Wenchang|文昌|44","group":"W"},{"display":"温州","data":"Wenzhou|温州|491","group":"W"},{"display":"乌海","data":"Wuhai|乌海|1133","group":"W"},{"display":"武汉","data":"Wuhan|武汉|477","group":"W"},{"display":"芜湖","data":"Wuhu|芜湖|478","group":"W"},{"display":"乌鲁木齐","data":"Wulumuqi|乌鲁木齐|39","group":"W"},{"display":"武威","data":"Wuwei|武威|664","group":"W"},{"display":"无锡","data":"Wuxi|无锡|13","group":"W"},{"display":"五指山","data":"Wuzhishan|五指山|46","group":"W"},{"display":"吴忠","data":"wuzhong|吴忠|7587","group":"W"},{"display":"梧州","data":"Wuzhou|梧州|492","group":"W"},{"display":"厦门","data":"Xiamen|厦门|25","group":"X"},{"display":"西安","data":"Xian|西安|10","group":"X"},{"display":"香港","data":"Hong Kong|香港|58","group":"X"},{"display":"湘潭","data":"Xiangtan|湘潭|598","group":"X"},{"display":"湘西","data":"xiangxi|湘西|3910","group":"X"},{"display":"襄阳","data":"Xiangyang|襄阳|496","group":"X"},{"display":"咸宁","data":"Xianning|咸宁|937","group":"X"},{"display":"咸阳","data":"Xianyang|咸阳|111","group":"X"},{"display":"孝感","data":"Xiaogan|孝感|1490","group":"X"},{"display":"锡林郭勒盟","data":"Xilinguole|锡林郭勒盟|7576","group":"X"},{"display":"新北","data":"Xinbeishi|新北|7662","group":"X"},{"display":"兴安盟","data":"xinganmeng|兴安盟|21021","group":"X"},{"display":"邢台","data":"Xingtai|邢台|947","group":"X"},{"display":"西宁","data":"Xining|西宁|124","group":"X"},{"display":"新乡","data":"Xinxiang|新乡|507","group":"X"},{"display":"信阳","data":"Xinyang|信阳|510","group":"X"},{"display":"新余","data":"Xinyu|新余|603","group":"X"},{"display":"忻州","data":"Xinzhou|忻州|513","group":"X"},{"display":"宣城","data":"Xuancheng|宣城|1006","group":"X"},{"display":"许昌","data":"Xuchang|许昌|1094","group":"X"},{"display":"徐州","data":"Xuzhou|徐州|512","group":"X"},{"display":"雅安","data":"yaan|雅安|3277","group":"Y"},{"display":"延安","data":"Yan'an|延安|110","group":"Y"},{"display":"盐城","data":"Yancheng|盐城|1200","group":"Y"},{"display":"阳江","data":"Yangjiang|阳江|692","group":"Y"},{"display":"阳泉","data":"Yangquan|阳泉|907","group":"Y"},{"display":"扬州","data":"Yangzhou|扬州|15","group":"Y"},{"display":"烟台","data":"Yantai|烟台|533","group":"Y"},{"display":"宜宾","data":"Yibin|宜宾|514","group":"Y"},{"display":"宜昌","data":"Yichang|宜昌|515","group":"Y"},{"display":"伊春","data":"Yichun|伊春|517","group":"Y"},{"display":"宜春","data":"Yichun|宜春|518","group":"Y"},{"display":"伊犁","data":"Yili|伊犁|98","group":"Y"},{"display":"银川","data":"Yinchuan|银川|99","group":"Y"},{"display":"营口","data":"Yingkou|营口|1300","group":"Y"},{"display":"鹰潭","data":"Yingtan|鹰潭|534","group":"Y"},{"display":"益阳","data":"Yiyang|益阳|1125","group":"Y"},{"display":"永州","data":"Yongzhou|永州|970","group":"Y"},{"display":"岳阳","data":"Yueyang|岳阳|539","group":"Y"},{"display":"玉林","data":"Yulin|玉林|1113","group":"Y"},{"display":"榆林","data":"Yulin|榆林|527","group":"Y"},{"display":"运城","data":"Yuncheng|运城|140","group":"Y"},{"display":"云浮","data":"yunfu|云浮|3933","group":"Y"},{"display":"云林市","data":"yunlin|云林市|7523","group":"Y"},{"display":"玉溪","data":"Yuxi|玉溪|186","group":"Y"},{"display":"枣庄","data":"Zaozhuang|枣庄|614","group":"Z"},{"display":"张家界","data":"Zhangjiajie|张家界|27","group":"Z"},{"display":"张家口","data":"Zhangjiakou|张家口|550","group":"Z"},{"display":"张掖","data":"Zhangye|张掖|663","group":"Z"},{"display":"漳州","data":"Zhangzhou|漳州|560","group":"Z"},{"display":"湛江","data":"Zhanjiang|湛江|547","group":"Z"},{"display":"肇庆","data":"Zhaoqing|肇庆|552","group":"Z"},{"display":"昭通","data":"Zhaotong|昭通|555","group":"Z"},{"display":"郑州","data":"Zhengzhou|郑州|559","group":"Z"},{"display":"镇江","data":"Zhenjiang|镇江|16","group":"Z"},{"display":"中山","data":"Zhongshan|中山|553","group":"Z"},{"display":"中卫","data":"Zhongwei|中卫|556","group":"Z"},{"display":"周口","data":"zhoukou|周口|3221","group":"Z"},{"display":"舟山","data":"Zhoushan|舟山|19","group":"Z"},{"display":"珠海","data":"Zhuhai|珠海|31","group":"Z"},{"display":"驻马店","data":"Zhumadian|驻马店|551","group":"Z"},{"display":"株洲","data":"Zhuzhou|株洲|601","group":"Z"},{"display":"淄博","data":"Zibo|淄博|542","group":"Z"},{"display":"自贡","data":"Zigong|自贡|544","group":"Z"},{"display":"资阳","data":"Ziyang|资阳|1560","group":"Z"},{"display":"遵义","data":"Zunyi|遵义|558","group":"Z"}];
    for city in ctripCity:
        cityName = city['display'];
        dist = queryCityCodeByName(cityName);
        if(dist is None):
            continue;
        updateSpideredCity(dist['city'], dist['name']);
        for hotel in queryAllHotelList(cityName):
            #print(hotel);
            if(queryHotelInfoExist(hotel['HOTEL_ID']) == False):
                hotel_info = fetch_hotel_info(hotel['HOTEL_ID'], hotel['CITY']);
                if(hotel_info is not None):
                    saveOrUpdateHotelInfo(hotel_info);
        print('从携程官网获取'+cityName +'的所有青旅详细信息成功!');

#test
#fetHotelInfosFromCtrip('北京');
#fetchHotelListFromCtrip(1, '北京');

if __name__ == '__main__':
    main(sys.argv)






